package algoritm;

public class cl {

	public static void main(String[] args) {
		int a=12345, b= 125;
		long start = System.nanoTime();
		evklid(a,b);
		perebor(a,b);
		svou(a,b);
		long end = System.nanoTime();
		long traceTime = end-start;
		System.out.println(traceTime);
	}
	public static void evklid(int a,int b){
		while (a!=0 && b!=0) {
			if (a>b)
			a=a%b;
			else
			b=b%a;
			}
			System.out.println(a+b);
	}
	public static void perebor(int a,int b){
	if (a!=0 && b!=0){
		int k=a;
		while(a%k!=0 || b%k!=0){
			k=k-1;
		}
		System.out.println(k);
		}
	}
	public static void svou(int a,int b){
		if (a!=0 && b!=0){
			if(a%2==0 && b%2==0){
				int k=a;
				while(a%k!=0 || b%k!=0){
					k=k-2;
				}
				System.out.println(k);
			}
			else{
				int k=a;
				while(a%k!=0 || b%k!=0){
					k=k-1;
				}
				System.out.println(k);
			}
		}
		
	}	
}

